<?php
class ez_Mysql extends ez_Abstract
{
	private $_connection;
	
	public function setDatabase($database)
	{
		if ($this->_connection) {
			mysql_select_db($database, $this->_connection);
		}
	}
	
	public function setCharset($charset)
	{
		if ($this->_connection) {
			mysql_query('SET NAMES '.$charset, $this->_connection);
		}
	}
	
	public function connect($server,$uid,$password)
	{
		$this->_connection = mysql_connect($server,$uid,$password);
	}
	
	public function query($sql)
	{
		if ($this->_connection) {
			mysql_query($sql,$this->_connection);
		}
	}
	
	public function queryTable($sql)
	{
		if ($this->_connection) {
			$result = myql_query($sql, $this->_connection); 
			$dataset = array();
			while ($row = mysql_fetch_assoc($result)) {
				$dataset[] = $row;
			}
			return $dataset;
		}
	}
	
	public function queryRow($sql)
	{
		if ($this->_connection) {
			$result = myql_query($sql, $this->_connection);
			return mysql_fetch_assoc($result);
		}
	}
	
	public function queryData($sql)
	{
		if ($this->_connection) {
			$result = myql_query($sql, $this->_connection);
			$row = mysql_fetch_row($result);
			return $row[0];
		}
	}	
}